package com.lighting.lightingservice.controller;

import com.lighting.lightingservice.dto.Page;
import com.lighting.lightingservice.dto.Video;
import com.lighting.lightingservice.mapper.VideoMapper;
import com.lighting.lightingservice.service.DataService;
import com.lighting.lightingservice.service.VideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class VideoController {
    @Autowired
    private VideoService videoService;
    @Autowired
    private VideoMapper videoMapper;

    @RequestMapping("/video")
    @ResponseBody
    @CrossOrigin
    List<Video> allVideos() {

        return  videoService.getVideoByDB();
    }

    @RequestMapping("/mainVideo")
    @ResponseBody
    @CrossOrigin
    String setDataForMainVideo(String mainVideo){
        videoService.setMainVideo(mainVideo);
        return mainVideo;
    }

    @RequestMapping("/blockVideo1")
    @ResponseBody
    @CrossOrigin
    String setDataForBlockVideo1(String blockVideo1){
        videoService.setBlockVideo1(blockVideo1);
        return blockVideo1;
    }

    @RequestMapping("/blockVideo2")
    @ResponseBody
    @CrossOrigin
    String setDataForBlockVideo2(String blockVideo2){
        videoService.setBlockVideo2(blockVideo2);
        return blockVideo2;
    }

    @RequestMapping("/blockVideo3")
    @ResponseBody
    @CrossOrigin
    String setDataForBlockVideo3(String blockVideo3){
        videoService.setBlockVideo3(blockVideo3);
        return blockVideo3;
    }

    @RequestMapping("/blockVideo4")
    @ResponseBody
    @CrossOrigin
    String setDataForBlockVideo4(String blockVideo4){
        videoService.setBlockVideo4(blockVideo4);
        return blockVideo4;
    }

    //***********************测试区*****************************

    @RequestMapping("/videoInsert")
    @ResponseBody
    @CrossOrigin
    void insertVideo(String name, String url){
        videoService.insertVideo(name, url);
    }

    @RequestMapping("/videoDel")
    @ResponseBody
    @CrossOrigin
    void deleteVideo(String name){
        videoService.deleteVideo(name);
    }
}
